import axios from './http';
import { HttpResponse } from '../types/HttpResponse';

interface Url {
  [key: string]: string;
}
const url: Url = {
  getEx: '/ex/get',
  postEx: '/ex/post',
};

//封装接口方法
export class Example {
  //get example
  static async getEx(params: { id: number }): Promise<HttpResponse> {
    return axios(url.getEx, {
      method: 'get',
      responseType: 'json',
      params: params,
    });
  }
  //post example
  static async postEx(data: { id: number }): Promise<HttpResponse> {
    return axios(url.postEx, {
      method: 'post',
      responseType: 'json',
      data: data,
    });
  }
}
